package com.gpj.learn.rabbitmq.workqueue;

import com.gpj.learn.rabbitmq.common.CommonConstants;
import com.gpj.learn.rabbitmq.common.RabbitUtil;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

/**
 * @className WorkQueueProducer
 * @description
 *   TODO
 * @author GPJ
 * @date 2021/5/30 12:33
 * @version 1.0
 **/
@Slf4j
public class WorkQueueProducer {
	public static void main(String[] args) throws IOException {
		log.info("------------- 开始发送消息 -------------");
		Channel channel = RabbitUtil.createChannel(CommonConstants.RABBITMQ_QUEUE_WORKQUEUE);

		String meaasge = "workqueue message no.";
		for (int i = 0; i < 20; i++) {
			channel.basicPublish("",
					CommonConstants.RABBITMQ_QUEUE_WORKQUEUE, null, (meaasge + i).getBytes());
		}
		RabbitUtil.close(channel);
		log.info("------------- 消息发送完成 -------------");
	}
}
